﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.DTOs.ReportDTOs;
using Traceability.Commont.DTOs.WhiteStripWeighingHtmlGroup;
using U.Enterprise.Api.Applications.DetailsFiles;
using U.Enterprise.Api.Applications.EndingOnly;
using U.Enterprise.Api.Applications.PartitionWarehousings;
using U.Enterprise.Api.Applications.Reports;
using U.Enterprise.Api.Applications.SalesWeighingEXE;
using U.Enterprise.Api.Applications.SalesWeighings;
using U.Enterprise.Api.Applications.SplitDetails;

namespace U.Enterprise.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EndingController : ControllerBase
    {


        private readonly IMediator _mediator;

        public EndingController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 划膘添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> ProductionScratchesCreate(ProductionScratchesCreateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 划膘显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<ProductionScratches>> ProductionScratchesHTml(ProductionScratchesHTmlCommondcs request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _mediator.Send(request);
                return list;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 划膘修改 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> ProductionScratchesupdate(ProductionScratchesupdateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 划膘删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Resqults> ProductionScratchesdeel(ProductionScratchesdeelCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }
        /// <summary>
        /// 销售添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<Resqults> SalesWeighingCreate(SalesWeighingCreateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 销售显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<SalesWeighing>> SalesWeighingHtml(SalesWeighingHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _mediator.Send(request);
                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 销售修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SalesWeighingupdate(SalesWeighingupdateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }
        /// <summary>
        /// 销售删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SalesWeighingDel(SalesWeighingDelCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }
        /// <summary>
        /// 销售分组
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SaleGroupDTO>> SaleGroup(SalesGroupCommand info)
        {
            var list= await _mediator.Send(info);
            return list;
        }
        /// <summary>
        /// 分割入库新增1
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SplitRUCreate(SplitRUCreateCommond request, CancellationToken cancellationToken)
        {
            var list =  await _mediator.Send(request);
            return list;
        }
        /// <summary>
        /// 分割入库显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        [HttpPost]
        public async Task<PageDTO<SplitRU>> SplitRUHtml(SplitRUHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _mediator.Send(request);
                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// 分割入库删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SplitRUDel(SplitRUDelCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 分割入库反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SplitRUBack(SplitRUBackCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);


            return list;


        }



        /// <summary>
        /// 分割入库修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> SplitRUupdate(SplitRUupdateCommond request, CancellationToken cancellationToken)
        {
            var query = await _mediator.Send(request);
            return query;
        }
        /// <summary>
        /// 分割入库分组显示
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SpliteWightGroupDTO>> groupSplit(SpliteRUGroupCommand info)
        {
            try
            {
                var res =await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 油表称重添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> WeighTheFatCreate(WeighTheFatCreateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 油表称重修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> WeighTheFatUpdate(WeighTheFatUpdateCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 油表称重删除
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults> WeighTheFatDel(WeighTheFatDelCommond request, CancellationToken cancellationToken)
        {
            var list = await _mediator.Send(request);
            return list;
        }

        /// <summary>
        /// 油表称重显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageDTO<WeighTheFat>> HandleList(WeighTheFatHtmlCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list =await _mediator.Send(request);
                return list;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// 膘油称重分组显示
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public  async Task<Resqults<WeighTheFatGroupList>> getGrouuWight(WeighTheFatGroupCommand info)
        {
            try
            {
                var res=await _mediator.Send(info); 
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 进场登记报表显示
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<Approach>> GetApproachDetail(ApproachDetailsCommand info)
        {
            try
            {
                var res= await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 白条称重明细表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<WhiteBarDatileDTO>> PostWhiteBarDetil(WhiteBarDetailsCommand info)
        {
            try
            {
                var res = await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 白条称重汇总表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<WhiteSummaryDTO>> PostWhiteBarForm(WhiteSummaryCommand info)
        {
            try
            {
                var res =await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 分割入库称重明细表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SplitDetailtDTO>> postSplitDetil(SplitDetailsCommand info)
        {
            try
            {
                var res=await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 分割入库汇总表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SplitSummaryDTO>> postSplitSummary(SplitsSummaryCommand info)
        {
            try
            {
                var res= await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 销售明细表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SalesDetailsDTO>> postSaleDetasil(SaleDetailsCommand info)
        {
            try
            {
                var res =await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 销售汇总表 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Resqults<SaleSummaryDTO>> postSaleSummary(SaleSummaryCommand info)
        {
            try
            {
                var res =await _mediator.Send(info);
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
